<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
   <script>
        var str1 = '12'
        var str2 = '13.3445'
        var str3 = '50px'
        var str4 = 'dd58'

        console.log(parseInt(str1));//12
        console.log(parseInt(str2));//13
        console.log(parseInt(str3));//50
        console.log(parseInt(str4));//NaN

        console.log(parseFloat(str1));//12
        console.log(parseFloat(str2));//13.3345
        console.log(parseFloat(str3));//50

        console.log(Number(str1));//12
        console.log(Number(str2));//13.3445
        console.log(Number(str3));//NaN

        //隐式转换
        console.log(+str1);//12
        console.log(str2-0);//13.3445
   </script>
</body>
</html>